
export default G6 => {
    G6.registerBehavior('hover-node', {
        getDefaultCfg() {
            return {
                multiple: false // 多选
            }
        },
        getEvents() {
            return {
                'node:mouseenter': 'onNodeMouseEnter',
                'node:mousemove': 'onNodeMouseMove',
                'node:mouseleave': 'onNodeMouseLeave'
            }
        },
        onNodeMouseEnter(e) {
            const graph = this.graph;
            const item = e.item;
            if (!item.hasState('nodeState:selected')) {
                graph.setItemState(item, 'nodeState', 'hover');
            }
            // 锚点显示
            graph.setItemState(item, 'anchorShow', true); // 二值状态
            // mouseenter回调
            graph.emit('on-node-mouseenter', e);
        },
        onNodeMouseMove(e) {
            this.graph.emit('on-node-mousemove', e);
        },
        onNodeMouseLeave(e) {
            const graph = this.graph;
            const item = e.item;
            if (item.hasState('nodeState:hover')) {
                graph.setItemState(item, 'nodeState', 'default');
            }
            // 锚点显示
            graph.setItemState(item, 'anchorShow', false);
            // mouseleave回调
            graph.emit('on-node-mouseleave', e);
        }
    })
}